﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentManage.Data;
using StudentManage.Common;

namespace StudentManage.Web.Personal
{
    public partial class EditPassWord : SecurityPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            UserList md = (UserList)Session["UserMD"];
            if (md.PassWord != Utility.GetMD5PassWord(this.txt_OldPassWord.Text.Trim(), ""))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('原密码输入不正确！');</script>");
            }
            else
            {
                md.PassWord = Utility.GetMD5PassWord(this.txt_NewPassWord.Text.Trim(), "");
                UserList.Update(md, "id=@0", md.id);
                Session["UserMD"] = md;
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改成功！');</script>");
            }
        }
    }
}